import 'package:get/get.dart';
import 'package:star_author/env/env_config.dart';
import 'package:star_author/utils/http/http_util.dart';

import '../../user_util.dart';
import '../statistics.dart';

class HuiLiuStatistics implements BaseStatistics {
  String prod = "https://concerto.huiliu.net";

  String dev = "https://dev-concerto.huiliu.net";

  getPath() {
    return EnvConfig.isProd() ? prod : dev;
  }

  HuiLiuStatistics._internal();

  factory HuiLiuStatistics() => _instance;

  static late final HuiLiuStatistics _instance = HuiLiuStatistics._internal();

  @override
  event(event_name, args) {
    if (!UserUtil.isLogin(Get.context!)) {
      return;
    }
    HttpUtil.commonRequest(
      Get.context!,
      getPath() + "/api/v1/collector_logs",
      data: {
        "content_id": args['id'],
        "user_id": UserUtil.getUserId(Get.context!).toString(),
        "event": event_name,
      },
      isLoading: false,
      isCatchErrorLogin: false,
      isErrorToast: false,
      method: HttpUtil.MethodPost,
    );
  }

  @override
  init() {}

  @override
  login() {}

  @override
  logout() {}

  @override
  pageEnd(name) {}

  @override
  pageStart(name) {}
}
